{% extends "topic/base.html" %}
{% block title %}个人主页{% endblock%}
{% block main %}

<div id="main">
  <div id="sidebar">
    <div class="panel">
      <div class="header">
        <span class="col_fade">个人信息</span>
      </div>
      <div class="inner">
        <div class="user_card">
          <div>
            <a class="user_avatar" href="{{ url_for('index.user_detail', id=user.id) }}">
            <img src="{{ user.image }}" title="{{ user.username }}">
            </a>
            <span class="user_name">
                <a class="dark" href="{{ url_for('index.user_detail', id=user.id) }}">
                    {{ user.username }}
                </a>
            </span>
            <div class="board clearfix"></div>
            <div class="space clearfix"></div>
            <span class="signature">
                {{ user.signature }}
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div id="content">
      <div class="panel">
        <div class="header">
          <ul class="breadcrumb">
            <li>主页</a><span class="divider">/</span></li>
          </ul>
        </div>
        <div class="inner userinfo">
          <div class="user_big_avatar" >
            <img src="{{ user.image }}" class="user_avatar" title="{{ user.username }}">
          </div>
          <a class="dark" title="{{ user.username }}"></a>

          <div class="user_profile">
            <ul class="unstyled">
              <li>
                <a class="dark" href="{{ url_for('index.user_detail', id=user.id) }}" target="_blank">
                  @{{ user.username }}
                </a>
              </li>
            </ul>
          </div>
          <p class="col_fade">注册时间 {{ user.created_time | history_time }}前</p>

        </div>
      </div>

      <div class="panel">
        <div class="header">
          <span class="col_fade">最近创建的话题</span>
        </div>
        {% for t in created %}
        {% set re = t.replies() %}
          <div class="cell">
            <a class="user_avatar pull-left" href="{{ url_for('index.user_detail', id=user.id) }}">
            <img src="{{ user.image }}" title="{{ user.username }}"/>
                {{ user.username }}
            </a>

            <span class="reply_count pull-left">
                <span class="count_of_replies" title="回复数">
                  {{ t.reply_count() }}
                </span>
                <span class="count_seperator">/</span>
                <span class="count_of_visits" title='点击数'>
                  {{ t.views }}
                </span>
            </span>
            {% if re == [] %}
                <span class='last_time pull-right'>
                    <span class="last_active_time">{{ t.created_time | history_time }} 前</span>
                </span>
            {% else %}
                <a class='last_time pull-right' href="{{ url_for('index.user_detail', id=re[-1].user().id) }}">
                    <img class="user_small_avatar" src="{{ re[-1].user().image }}">
                    <span class="last_active_time">{{ re[-1].created_time | history_time }} 前</span>
                </a>
            {% endif %}
            <div class="topic_title_wrapper">
              <a class='topic_title' href="{{ url_for('topic.detail', id=t.id) }}" title="{{ t.title }}">
                  {{ t.title }}
              </a>
            </div>
          </div>
        {% endfor %}
      </div>

      <div class="panel">
        <div class="header">
          <span class="col_fade">最近参与的话题</span>
        </div>
        {% for r in replied %}
          {% set u = r.user() %}
          {% set re = r.replies() %}
          <div class="cell">
            <a class="user_avatar pull-left" href="{{ url_for('index.user_detail', id=u.id) }}">
            <img src="{{ u.image }}" title="{{ u.username }}"/>
                {{ u.username }}
            </a>

            <span class="reply_count pull-left">
                <span class="count_of_replies" title="回复数">
                  {{ r.reply_count() }}
                </span>
                <span class="count_seperator">/</span>
                <span class="count_of_visits" title='点击数'>
                  {{ r.views }}
                </span>
            </span>

            <a class='last_time pull-right' href="{{ url_for('index.user_detail', id=re[-1].user().id) }}">
                <img class="user_small_avatar" src="{{ re[-1].user().image }}">
                <span class="last_active_time">{{ re[-1].created_time | history_time }} 前</span>
            </a>

            <div class="topic_title_wrapper">
              <a class='topic_title' href="{{ url_for('topic.detail', id=r.id) }}" title="{{ r.title }}">
                  {{ r.title }}
              </a>
            </div>
          </div>
        {% endfor %}
      </div>
  </div>
</div>


{% endblock %}